<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="codemirror/js/codemirror.js" type="text/javascript"></script>
    <title>CodeMirror: Ruby demonstration</title>
    <style type="text/css">
      .CodeMirror-line-numbers {
        width: 2.2em;
        color: #999;
        background-color: #333;
        text-align: right;
        padding: .4em;
        margin: 0;
        font-size: 12pt;
        line-height: 1.1em;
        font-family: consolas, monospace;
      }
    </style>
</head>
<body>

<h1>CodeMirror Ruby highligting</h1>

<ul>
<li>author: <a href="mailto:michal@hantl.cz">michal@hantl.cz</a></li>
<li>version : 0.1.8</li>
</ul>

<div style="border: 1px solid black; padding: 0px;">
<textarea id="code" cols="100" rows="40" style="width:100%">

  ROADMAP = [
    '0.2 milestone' => [
        :variables_vs_method_calls
        :blocks_and_params,
        :indentation
      ]
    '0.3 milestone' => [
        :mark_some_syntax_errors,
        :simple_markup_in_long_comments
      ]
    ]

  NICE_TO_HAVE = [
    :current_line_highlight,
    :better_HEREDOC # not sure, netbeans doesnt support complex heredoc either
  ]
  
class DinersController < UsersController::SomeOther::NameSpace

    __FILE__
    ANOTHER_CONSTANT
    
    acts_as_ruby_editor :version => '1.8'
    
    # long comment

=begin
  long, entertaining comment

  =begin
    just checking
  =end
=end  

  def test_classes
    ClassName
    CONSTANT_NAME
    test(InsideBraces)
  end
  
  def global_variables
    $global_vars
    begin
      do_something_dangerous
    rescue
      puts "the exception was #{$!}."      
    end  
  end
  
  def regexps
    email =~ /[a-z0-9!#\$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
  end

  # GET /diners
  def index
    @diners = Diner.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @diners }
    end
  end

  def highlights_question_marks?
    exclamation_marks_too!
  end
  
  def operators
    array = []
    array << 'item'
    "hello " += 'world'
    128 -= 4
    128 *= 2
    15..15      #.to_a == [12, 13, 14, 15]
    12...15     #.to_a == [12, 13, 14]
    'a'..'z'
  end
  
  def string
    'type \'h\' for help'                 #single quotes
    "this \"is\" a string expression\n"   #double quotes
    "string #{ with(:ruby).inside }"      #double quotes with ruby
    'concat#{foobar}'                     #no ruby here
    "here are some random numbers #{(0..10).collect {(100*rand).to_i}.sort.inspect}"
  end
  
  def special_string
    %w{apple #{ 123 } cherry}                       #array of words
    %W{apple #{ 123 } cherry}                       #array of words
    %q!I said, "You said, 'She said #{123}.'"!      #q
    %Q('This is #{ 123 }.'\n)                       #Q
    %!I said, "You said, 'She said it.'"!           #custom char
    %!I said, "You said, 'She said #{ 123 }.'"!     #custom char
    `exec #{create_options}`
  end
  
  def number_literals
    123       #integer
    -123      #integer(signed)
    1_234     #integer(underscore within decimal numbers ignored)
    123.45    #floating point number
    1.2e-3    #floating point number
    0xffff    #hexadecimal integer
    0b01011   #binary integer
    0377      #octal integer
    ?a        #ASCII code for character `a'(97)
    ?\C-a     #Control-a(1)
    ?\M-a     #Meta-a(225)
    ?\M-\C-a  #Meta-Control-a(129)
    :symbol   #Integer corresponding identifiers, variable names, and operators.
  end
  
  def heredoc
    <<EOF
    The price is #{$Price}.
    EOF
  
    # those are not supported for now
  
    "EOF";			# same as above
    The price is #{$Price}.
    EOF
  
    print <<`EOC`			# execute commands
    echo hi there
    echo lo there
    EOC
  
    print <<"foo", <<"bar"	# you can stack them
    I said foo.
    foo
    I said bar.
    bar
  
    myfunc(<<"THIS", 23, <<'THAT')
    Here's a line
    or two.
    THIS
    and here's another.
    THAT
  
    eval <<-EOS			# delimiters can be indented
      def foo
       print "foo\n"
      end
    EOS
  end

end

</textarea>
</div>

<script type="text/javascript">
    var editor = CodeMirror.fromTextArea('code', {
        parserfile: ["../../js/parseruby.js"],
        stylesheet: "css/rubycolors.css",
        path: "codemirror/js/",
        lineNumbers: true,
        textWrapping: false,
        indentUnit: 4,
        parserConfig: {},
        height: '80%'
    });
</script>
</body>
</html>
